home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Ham⁄GPS / SoftKiss.src.1.8 Folder / SoftKiss.src.1.8 / core / sfk_core.h < prev   
Text File  |  1993-03-12  |  7KB  |  218 lines

  1. /*
  2.  * SoftKiss
  3.  * by Aaron Wohl / N3LIW (aw0g+@andrew.cmu.edu) jul 1990
  4.  * 6393 Penn Ave #303
  5.  * Pittsburgh PA, 15206
  6.  * work: (412)-268-5032
  7.  * home: (412)-731-6159
  8.  */
  9.  
  10. #pragma once
  11.  
  12. #ifndef sfk_ABSOULTE_SIZE_INTS_DEFINED
  13. #include "sfk_types.h"
  14. #endif
  15.  
  16. /*
  17.  * driver major and minor version numbers
  18.  * send it these number from when your program was compiled
  19.  * if it is too new or too old to emulate the version you
  20.  * ask for it will fail to let you attach to a port
  21.  */
  22. #define sfk_ST_maj_ver (17)
  23. #define sfk_ST_min_ver (23)
  24.  
  25.  
  26. /*
  27.  * data for reading/writing a packet
  28.  * on write cnt bytes are written
  29.  * on read cnt is the size of the buffer available it is updated
  30.  * to be the count of actual bytes available
  31.  */
  32. struct sfk_packet_R {
  33.     struct sfk_packet_R *next; /*used internaly, must be first*/
  34. #define SFK_ufirst         (1)    /*this read call was the first to return this packet*/
  35. #define sfk_db_SHORT    (2)    /*packet is too short to be leagle*/
  36. #define sfk_db_LONG        (4)    /*packet is too long to fit in queue or recieve*/
  37. #define sfk_db_CRC        (8)    /*packet had bad CRC*/
  38. #define sfk_db_BAD_AX25    (16) /*ax25 header is bad*/
  39. #define sfk_db_BAD        (32) /*something bad*/
  40. #define sfk_db_OVERRUN    (64) /*someone had interupts off too long*/
  41. #define sfk_db_DIBS        (128) /*a different attachment claimed this packet*/
  42.     uint32 data_flags;    /*[O]per packet flags*/
  43.     uint32 sfk_time_in;    /*[O]TickCount() when packet came in*/
  44.     uint8  portno;        /*port data comes in/out*/
  45.     uint8  sfk_xx_pad0;    /*reserved for expansion*/
  46.     uint16 cnt;            /*size of data to read/write*/
  47.     uint16 att_read;    /*attachments that handled this packet*/
  48.     uint8 *data;        /*[I]pointer to data to read/write*/
  49. };
  50. typedef struct sfk_packet_R sfk_packet,*sfk_packet_pt;
  51.  
  52. /*
  53.  * well known packet ports
  54.  */
  55. #define sfk_PRINTER_PORT     (0)
  56. #define sfk_MODEM_PORT         (1)
  57. #define sfk_NUM_MAGIC_PORTS (2)
  58.  
  59. /*
  60.  * ports after last well known are dynamicly assigned
  61.  */
  62. #define sfk_NUM_PORTS        (2)
  63.  
  64. /*
  65.  * maximum length of short string variables (callsigns) including nulls
  66.  */
  67. #define    sfk_STRING_SIZE    (16)
  68.  
  69. /*
  70.  * possible commands to driver
  71.  */
  72. #define sfk_CMD_goodbye      (-1)    /*goodbye kiss, the heap is about to be initilized*/
  73.                      /*   0      unused*/
  74. #define    sfk_CMD_killio    (1)        /*killio does this control entry to stop io*/
  75. #define sfk_CMD_run        (65)    /*run periodic functions*/
  76.  
  77. #define sfk_CMD_base    (100)    /*first command with extended error info*/
  78. #define sfk_CMD_attach    (100)    /*start useing ports*/
  79. #define sfk_CMD_detach    (101)    /*stop using ports*/
  80. #define sfk_CMD_msg     (102)     /*send driver a command message*/
  81. #define sfk_CMD_write    (103)    /*send a packet*/
  82. #define sfk_CMD_read    (104)    /*read a packet*/
  83.  
  84. /*
  85.  * common header record for all softkiss driver calls
  86.  * I - input only not modified
  87.  * O - output only, contents on call in don't matter
  88.  * IO - driver both reads then updates this field
  89.  */
  90. struct sfk_CMD_header_R {
  91.     uint32 att_num;        /*[IO]attachment port number*/
  92.     int16 sys_err_code;    /*[O]sytem error code, or zero on success*/
  93.     int16 sfk_err_code;    /*[O]sfk error code or zero on success*/
  94. };
  95. typedef struct sfk_CMD_header_R sfk_CMD_header,*sfk_CMD_header_pt;
  96.  
  97. /*
  98.  * string passed to driver for the driver to write to
  99.  */
  100. struct sfk_string_R {
  101.     int32 sfk_in_cnt;        /*size of input string*/
  102.     int32 sfk_out_cnt;        /*size used in output*/
  103.     char *sfk_str;            /*pointer to data*/
  104. };
  105. typedef struct sfk_string_R sfk_string,*sfk_string_pt;
  106.  
  107. /*
  108.  * text commands to send to SoftKiss and it's reply
  109.  */
  110. struct sfk_ARG_msg_R {
  111.     int portno;            /*[IO]default port*/
  112.     sfk_string imsg;    /*input message to sfk*/
  113.     sfk_string omsg;    /*output message from sfk*/
  114. };
  115. typedef struct sfk_ARG_msg_R sfk_ARG_msg,*sfk_ARG_msg_pt;
  116.  
  117. /*
  118.  * notify proc is called as follows
  119.  */
  120. #define sfk_NT_online     (1)    /*port just came online*/
  121. #define sfk_NT_offline     (2) /*port just went offline*/
  122. #define sfk_NT_read          (3)    /*here is a packet to read*/
  123. #define sfk_NT_ok_write (4) /*output write queue nearly empty, queue more writes now*/
  124.  
  125. typedef (*sfk_notify_proc)(int16 sfk_NT_cmd,int16 portno,sfk_packet_pt pkt);
  126.  
  127. /*
  128.  * input data to attach to a port
  129.  */
  130. struct sfk_ARG_attach_R {
  131.     sfk_notify_proc *notify_proc;     /*[I]routine to call for async notification*/
  132.     char *my_name;                    /*[I]description of what this program is/does*/
  133.     void *attachment_private_vars;    /*[I]pass this to notify proc*/
  134. };
  135. typedef struct sfk_ARG_attach_R sfk_ARG_attach,*sfk_ARG_attach_pt;
  136.  
  137. /*
  138.  * there is no input data to detach from a port, just the standard header
  139.  */
  140.  
  141. typedef int sfk_port_state;
  142. struct sfk_command_record_R {
  143.     sfk_CMD_header     sfk_hdr;    /*header common to all commands*/
  144.     union {
  145.         sfk_ARG_attach  sfk_attach; /*attach arguments*/
  146.         sfk_packet       sfk_rw;        /*data for read/write*/
  147.         sfk_ARG_msg        sfk_msg;    /*command message*/
  148.     }cknd;                            /*depends on command kind*/
  149. };
  150. typedef struct sfk_command_record_R sfk_command_record,*sfk_command_record_pt;
  151.  
  152. /*
  153.  * io manager control parameter block to pass to Control
  154.  */
  155. struct sfk_io_record_R {
  156.     void        *qLink;
  157.     short        qType;
  158.     short        ioTrap;
  159.     void        *ioCmdAddr;
  160.     void        *ioCompletion;
  161.     short        ioResult;
  162.     void        *ioNamePtr;
  163.     short        ioVRefNum;
  164.     short        ioRefNum;
  165.     short        csCode;
  166.     void         *private_state;    /*returned with pointer to drvr private vars*/    
  167.     sfk_command_record    do_this;    /*state to set, current state returned*/
  168. };
  169. typedef struct sfk_io_record_R sfk_io_record,*sfk_io_record_pt;
  170.  
  171. /*
  172.  * shortest legal packet not including CRC
  173.  */
  174. #define SFK_MIN_PACK_SIZE (15)
  175.  
  176. /*
  177.  * sfk error codes
  178.  */
  179. #define sfk_ERR_ISERR        0x020
  180.  
  181. #define sfk_ERR_NOERRR        (0)    /*no error*/
  182. #define sfk_ERR_TOO_OLD        (1)    /*driver to old to talk to server*/
  183. #define sfk_ERR_BAD_BAUD    (2)    /*zero or perposterious baud rate*/
  184. #define sfk_ERR_BAD_PARSE    (3)    /*parse of message to driver failed*/
  185. #define sfk_NOTHING_TO_READ    (4)    /*no packets available to read*/
  186.  /*driver understands the request but the code to do it isnt written
  187.   *yet.
  188.   */
  189. #define sfk_NOT_YET_IMPLEMENTED (5) 
  190. #define sfk_NO_SUCH_PORT    (5)    /*no such port online*/
  191.  
  192. /*
  193.  * initialize a parameter block for a control coll
  194.  */
  195. #define sfk_INIT_CPB(xx_pb,xx_ref,xx_cscode) \
  196.   do {(xx_pb).ioCompletion=0; \
  197.    (xx_pb).ioVRefNum=0; \
  198.    (xx_pb).ioRefNum=(xx_ref); \
  199.    (xx_pb).csCode=(xx_cscode); \
  200.   } while(0)
  201.  
  202. /*
  203.  * setup an io record to send the driver a message
  204.  */
  205. void sfk_parse_from(sfk_io_record_pt cmd,
  206.     char *in_str,
  207.     int in_len,
  208.     char *out_str,
  209.     int out_len,
  210.     int def_port);
  211.  
  212. /*
  213.  * when we want to transmit we wait till the channel is clear
  214.  * then generate a random number between 0 and PERSISTANCE_LIMIT-1
  215.  * if the number we generate is less than or equal to the xmit_persist
  216.  * value we transmit if not we try again
  217.  */
  218. #define PERSISTANCE_LIMIT (1000L)